import React, { Component } from "react";
import { Card, Icon, Form, Input, Cascader, Button, message } from "antd";

class ProductAddUpdate extends Component {
  state = {
    options: [],
  };
  constructor(props) {
    super(props);
    this.pw = React.createRef();
    this.editor = React.createRef();
  }
  initOptions = async (categorys) => {
    const options = await categorys.map((c) => ({
      value: c._id,
      label: c.name,
      isLeaf: false,
    }));
    const { isUpdata, product } = this;
    const { pCategoryId } = product;
    if (isUpdata && pCategoryId !== 0) {
    }
  };
  render() {
    const { isUpdata, product } = this;
    const title = (
      <span>
        <span onClick={() => this.props.history.goBack()}>回退</span>
        <span>{isUpdata ? "修改商品" : "添加商品"}</span>
      </span>
    );
    const { getFieldDecorator } = this.props.form;
    return (
      <Card title={title}>
        <Form>
          <Item label="商品名称">
            {getFieldDecorator("name", {
              initialValue: product.name,
            })(<Input placeholder="请输入商品名称" />)}
          </Item>
          <Item label="商品描述">
            {getFieldDecorator("desc", {
              initialValue: product.desc,
            })(
              <TextArea
                placeholder="请输入商品描述"
                autosize={{ minRows: 2, maxRows: 6 }}
              />
            )}
          </Item>
          <Item>
            {getFieldDecorator("price", {
              initialValue: product.price,
            })(<Input type="number" placeholder="请输入商品价格" />)}
          </Item>
        </Form>
      </Card>
    );
  }
}

export default ProductAddUpdate;
